<template>
  <div class="exportTemplateDialog">
    <div id="print_main" :key="langKey">
      <div
        v-for="(item, index) in list"
        :key="index + 'list'"
        class="exportTemplate_main"
      >
        <div style="height: 20px"></div>
        <!-- 企业名称 -->
        <div class="exportTemplate_main_title">{{ item.corp_name }}</div>
        <div style="height: 20px"></div>
        <!-- 检查表明细 -->
        <table
          align="center"
          border
          cellpadding="5"
          cellspacing="0"
          width="65%"
        >
          <tbody>
            <tr class="no-break">
              <!-- 检查表 -->
              <td align="right" class="blue-label" width="30%">
                {{ translateTitle('label.menu.jianchabiao') }}
              </td>
              <td align="center" class="large-font-size">
                {{ item.list_name }}
              </td>
            </tr>
            <tr class="no-break">
              <!--  店铺 -->
              <td align="right" class="blue-label">
                {{ translateTitle('label.menu.dianpu') }}
              </td>
              <td align="center" class="large-font-size">
                {{ item.org_name }}
              </td>
            </tr>
            <tr class="no-break">
              <!--  检查月份 -->
              <td align="right" class="blue-label">
                {{ translateTitle('label.menu.jianchayuefen') }}
              </td>
              <td align="center" class="large-font-size">
                {{
                  isTemplate
                    ? ''
                    : item.month
                    ? dayjs(item.month).format('YYYY/MM')
                    : ''
                }}
              </td>
            </tr>
            <tr class="no-break">
              <!--  检查日期 -->
              <td align="right" class="blue-label">
                {{ translateTitle('label.menu.jianchariqi') }}
              </td>
              <td align="center" class="large-font-size">
                {{ isTemplate ? '' : item.finish_time }}
              </td>
            </tr>
            <tr class="no-break">
              <!--  区域负责人 -->
              <td align="right" class="blue-label">
                {{ translateTitle('label.menu.quyufuzeren') }}
              </td>
              <td align="center" class="large-font-size">
                {{ item.sv_user_name }}
              </td>
            </tr>
            <tr class="no-break">
              <!--  店铺负责人 -->
              <td align="right" class="blue-label">
                {{ translateTitle('label.menu.dianpufuzeren') }}
              </td>
              <td align="center" class="large-font-size">
                {{ item.org_user_name }}
              </td>
            </tr>
            <tr class="no-break">
              <!--  检查者 -->
              <td align="right" class="blue-label">
                {{ translateTitle('label.menu.jianchazhe') }}
              </td>
              <td align="center" class="large-font-size">
                {{ isTemplate ? '' : item.user_name }}
              </td>
            </tr>
          </tbody>
        </table>
        <div style="height: 20px"></div>
        <!-- 总评价 -->
        <div
          class="exportTemplate_main_estimate no-break"
          v-html="
            isTemplate
              ? ''
              : item.estimate
              ? item.estimate.replace(/\n/g, '<br>')
              : ''
          "
        ></div>
        <div style="height: 20px"></div>
        <!-- 大项目得分率 -->
        <div class="exportTemplate_main_score">
          <div class="exportTemplate_main_score_head no-break">
            <div
              class="exportTemplate_main_score_head_item blue-label"
              style="flex: 1"
            >
              {{ translateTitle('label.menu.benhuijieguo') }}
            </div>
            <div
              class="exportTemplate_main_score_head_item blue-label"
              style="width: 33%"
            >
              {{ translateTitle('label.menu.shanghuijieguo') }}
            </div>
            <div
              class="exportTemplate_main_score_head_item blue-label"
              style="width: 33%"
            >
              {{ translateTitle('label.menu.shangshanghuijieguo') }}
            </div>
          </div>
          <div class="exportTemplate_main_score_main">
            <div
              v-for="itemCategory in item.item_category_scores"
              :key="itemCategory.item_ategory"
              class="exportTemplate_main_score_main_body no-break"
            >
              <div
                v-for="(count, countIndex) in 3"
                :key="itemCategory.item_ategory + count"
                class="exportTemplate_main_score_main_body_item"
                :style="{
                  flex: countIndex == 0 ? 1 : '0 1 auto',
                  width: countIndex ? '33%' : 'auto',
                }"
              >
                <div
                  :class="[
                    'exportTemplate_main_score_main_body_item_label blue-label',
                    countIndex == 0 ? 'border-right-none' : '',
                  ]"
                >
                  <template v-if="itemCategory.item_ategory">
                    {{
                      getCodeLabel(
                        `${qscCodesParentID.qscjianchadaxiangmu}.${itemCategory.item_ategory}`,
                        itemCategory.name
                      )
                    }}
                  </template>
                  <template v-else>
                    {{ translateTitle('label.menu.heji') }}
                  </template>
                </div>
                <div class="exportTemplate_main_score_main_body_item_content">
                  {{
                    isTemplate && countIndex == 0
                      ? ''
                      : itemCategory['scoring_average_' + countIndex] ||
                        itemCategory['scoring_average_' + countIndex] == 0
                      ? itemCategory['scoring_average_' + countIndex] + '%'
                      : itemCategory['scoring_average_' + countIndex]
                  }}
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- 得分详细a.b分 -->
        <div
          class="exportTemplate_main_inspection_top no-break page-break"
          style="
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: flex-end;
          "
        >
          <div style="height: 20px"></div>
          <table border cellpadding="5" cellspacing="0" width="40%">
            <tbody>
              <!-- A-结果输入栏合计 -->
              <tr>
                <td width="70%">
                  {{ translateTitle('label.menu.ajieguoshurulanheji') }}
                </td>
                <td align="center">
                  {{ isTemplate ? '' : item.total_score || 0 }}
                </td>
              </tr>
              <!-- B-满分 -->
              <tr>
                <td>{{ translateTitle('label.menu.bpingjiazhuanan') }}</td>
                <td align="center">
                  {{ isTemplate ? '' : item.scoring_pass || 0 }}
                </td>
              </tr>
              <!-- 得分率（A/B*100） -->
              <tr>
                <td>{{ translateTitle('label.menu.defenlv') }}</td>
                <td align="center">
                  {{ isTemplate ? '' : (item.scoring_average || 0) + '%' }}
                </td>
              </tr>
            </tbody>
          </table>
          <div style="height: 20px"></div>
        </div>
        <!-- 检查明细表 -->
        <div class="exportTemplate_main_inspection_details">
          <div class="exportTemplate_main_inspection_details_header">
            <!-- 大项目 -->
            <div
              class="exportTemplate_main_inspection_details_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column1'
                  ),
              }"
            >
              {{ translateTitle('label.menu.daxiangmu') }}
            </div>
            <!-- no -->
            <div
              class="exportTemplate_main_inspection_details_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column2'
                  ),
              }"
            >
              {{ translateTitle('label.menu.fanhao') }}
            </div>
            <!-- 确认内容 -->
            <div
              class="exportTemplate_main_inspection_details_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column3'
                  ),
              }"
            >
              {{ translateTitle('label.menu.querenneirong') }}
            </div>
            <!-- 检查项目 -->
            <div
              class="exportTemplate_main_inspection_details_header_item blue-label auto-width"
              :style="{
                'min-width': `calc(
                ${translateTitle(
                  'width.exportTemplateDialog.inspection_details.table_column4'
                )} +
                  ${translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column5'
                  )}
              )`,
              }"
            >
              {{ translateTitle('label.menu.pingfenjizhun') }}
            </div>
            <!-- 分数 -->
            <div
              class="exportTemplate_main_inspection_details_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column6'
                  ),
              }"
            >
              {{ translateTitle('label.menu.fenshu') }}
            </div>
            <!-- 结果栏 -->
            <div
              class="exportTemplate_main_inspection_details_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column7'
                  ),
              }"
            >
              {{ translateTitle('label.menu.jieguolan') }}
            </div>
            <!-- 过去三回 -->
            <div
              class="exportTemplate_main_inspection_details_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column8'
                  ),
              }"
            >
              {{ translateTitle('label.menu.guoqusanhui') }}
            </div>
            <!-- 改善项目 -->
            <div
              class="exportTemplate_main_inspection_details_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column9'
                  ),
              }"
            >
              {{ translateTitle('label.menu.ganshanxiangmu') }}
            </div>
          </div>
          <div
            v-if="item.inspectionList && item.inspectionList.length > 0"
            class="exportTemplate_main_inspection_details_main"
          >
            <template v-for="(inspect, inspectIndex) in item.inspectionList">
              <template
                v-if="
                  inspectIndex > 0 &&
                  inspect.pageIndex !=
                    item.inspectionList[inspectIndex - 1].pageIndex
                "
              >
                <div
                  :key="inspectIndex + 'emptyDiv'"
                  class="emptyDiv"
                  :style="{ height: inspect.blankHeight + 'px' }"
                ></div>
                <div
                  :key="inspectIndex + 'thead'"
                  class="exportTemplate_main_inspection_details_header"
                >
                  <!-- 大项目 -->
                  <div
                    class="exportTemplate_main_inspection_details_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.inspection_details.table_column1'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.daxiangmu') }}
                  </div>
                  <!-- no -->
                  <div
                    class="exportTemplate_main_inspection_details_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.inspection_details.table_column2'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.fanhao') }}
                  </div>
                  <!-- 确认内容 -->
                  <div
                    class="exportTemplate_main_inspection_details_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.inspection_details.table_column3'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.querenneirong') }}
                  </div>
                  <!-- 检查项目 -->
                  <div
                    class="exportTemplate_main_inspection_details_header_item blue-label auto-width"
                    :style="{
                      'min-width': `calc(
                ${translateTitle(
                  'width.exportTemplateDialog.inspection_details.table_column4'
                )} +
                  ${translateTitle(
                    'width.exportTemplateDialog.inspection_details.table_column5'
                  )}
              )`,
                    }"
                  >
                    {{ translateTitle('label.menu.pingfenjizhun') }}
                  </div>
                  <!-- 分数 -->
                  <div
                    class="exportTemplate_main_inspection_details_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.inspection_details.table_column6'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.fenshu') }}
                  </div>
                  <!-- 结果栏 -->
                  <div
                    class="exportTemplate_main_inspection_details_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.inspection_details.table_column7'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.jieguolan') }}
                  </div>
                  <!-- 过去三回 -->
                  <div
                    class="exportTemplate_main_inspection_details_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.inspection_details.table_column8'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.guoqusanhui') }}
                  </div>
                  <!-- 改善项目 -->
                  <div
                    class="exportTemplate_main_inspection_details_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.inspection_details.table_column9'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.ganshanxiangmu') }}
                  </div>
                </div>
              </template>
              <div
                :key="inspectIndex + 'inspectionList'"
                class="exportTemplate_main_inspection_details_main_item"
              >
                <!-- 大项目 -->
                <div
                  class="exportTemplate_main_inspection_details_main_item_value center right-border"
                  :style="{
                    flex:
                      '0 0 ' +
                      translateTitle(
                        'width.exportTemplateDialog.inspection_details.table_column1'
                      ),
                  }"
                >
                  <div class="itemAtegory">
                    <div
                      v-for="(
                        itemAtegoryChild, itemAtegoryIndex
                      ) in inspect.item_ategory_list"
                      :key="itemAtegoryIndex + 'item_ategory_list'"
                    >
                      {{
                        translateTitle(itemAtegoryChild.key, true) ||
                        itemAtegoryChild.name
                      }}
                    </div>
                  </div>
                </div>
                <div
                  class="exportTemplate_main_inspection_details_main_item_right"
                >
                  <div
                    v-for="(
                      childInspect, childInspectIndex
                    ) in inspect.children"
                    :key="inspectIndex + 'inspectionList' + childInspectIndex"
                    class="exportTemplate_main_inspection_details_main_item_childInspect"
                    :class="childInspectIndex > 0 ? 'topBorder' : ''"
                  >
                    <!-- no -->
                    <div
                      class="exportTemplate_main_inspection_details_main_item_value center"
                      :style="{
                        flex:
                          '0 0 ' +
                          translateTitle(
                            'width.exportTemplateDialog.inspection_details.table_column2'
                          ),
                      }"
                    >
                      {{
                        caccumulationNo(
                          inspectIndex,
                          childInspectIndex,
                          item.inspectionList
                        )
                      }}
                    </div>
                    <!-- 确认内容 -->
                    <div
                      class="exportTemplate_main_inspection_details_main_item_value"
                      :style="{
                        flex:
                          '0 0 ' +
                          translateTitle(
                            'width.exportTemplateDialog.inspection_details.table_column3'
                          ),
                      }"
                    >
                      <span
                        class="rich-text-pc"
                        v-html="childInspect.item_content"
                      ></span>
                    </div>
                    <!-- 检查项目 -->
                    <div
                      class="exportTemplate_main_inspection_details_main_item_project auto-width"
                      :style="{
                        'min-width': `calc(
                      ${translateTitle(
                        'width.exportTemplateDialog.inspection_details.table_column4'
                      )} +
                        ${translateTitle(
                          'width.exportTemplateDialog.inspection_details.table_column5'
                        )}
                    )`,
                      }"
                    >
                      <div
                        class="exportTemplate_main_inspection_details_main_item_project_item auto-width"
                      >
                        <!-- 不具备评分条件 -->
                        <div
                          class="exportTemplate_main_inspection_details_main_item_value auto-width"
                          :style="{
                            'min-width': translateTitle(
                              'width.exportTemplateDialog.inspection_details.table_column4'
                            ),
                          }"
                        >
                          {{
                            translateTitle('label.menu.bujubeipingfentiaojian')
                          }}
                        </div>
                        <div
                          class="exportTemplate_main_inspection_details_main_item_value center"
                          :style="{
                            flex:
                              '0 0 ' +
                              translateTitle(
                                'width.exportTemplateDialog.inspection_details.table_column5'
                              ),
                          }"
                        >
                          <img
                            v-if="!isTemplate && childInspect.rating_condition"
                            class="is-checked"
                            src="@/assets/checked.png"
                          />
                          <div v-else class="custom_check"></div>
                        </div>
                      </div>
                      <div
                        v-for="(
                          standardItem, standardIndex
                        ) in childInspect.standard"
                        :key="standardIndex + 'standard'"
                        class="exportTemplate_main_inspection_details_main_item_project_item"
                      >
                        <div
                          class="exportTemplate_main_inspection_details_main_item_value auto-width"
                          :style="{
                            'min-width': translateTitle(
                              'width.exportTemplateDialog.inspection_details.table_column4'
                            ),
                          }"
                        >
                          <span
                            class="rich-text-pc"
                            v-html="standardItem.standard"
                          ></span>
                        </div>
                        <div
                          class="exportTemplate_main_inspection_details_main_item_value center"
                          :style="{
                            flex:
                              '0 0 ' +
                              translateTitle(
                                'width.exportTemplateDialog.inspection_details.table_column5'
                              ),
                          }"
                        >
                          <img
                            v-if="
                              !isTemplate &&
                              childInspect.inspection_item &&
                              childInspect.inspection_item.includes(
                                standardIndex
                              )
                            "
                            class="is-checked"
                            src="@/assets/checked.png"
                          />
                          <div v-else class="custom_check"></div>
                        </div>
                      </div>
                    </div>
                    <!-- 分数 -->
                    <div
                      class="exportTemplate_main_inspection_details_main_item_value center column"
                      :style="{
                        flex:
                          '0 0 ' +
                          translateTitle(
                            'width.exportTemplateDialog.inspection_details.table_column6'
                          ),
                      }"
                    >
                      <div class="score_area">
                        <div>{{ childInspect.min_score }}</div>
                        <div>~</div>
                        <div>{{ childInspect.max_score }}</div>
                      </div>
                    </div>
                    <!-- 结果栏 -->
                    <div
                      class="exportTemplate_main_inspection_details_main_item_value center"
                      :style="{
                        flex:
                          '0 0 ' +
                          translateTitle(
                            'width.exportTemplateDialog.inspection_details.table_column7'
                          ),
                      }"
                    >
                      {{ isTemplate ? '' : childInspect.score }}
                    </div>
                    <!-- 过去三回 -->
                    <div
                      class="exportTemplate_main_inspection_details_main_item_value center column"
                      :style="{
                        flex:
                          '0 0 ' +
                          translateTitle(
                            'width.exportTemplateDialog.inspection_details.table_column8'
                          ),
                      }"
                    >
                      <div>
                        {{
                          childInspect.history_score_1 ||
                          childInspect.history_score_1 === 0
                            ? childInspect.history_score_1
                            : '&nbsp;'
                        }}
                      </div>
                      <div>
                        {{
                          childInspect.history_score_2 ||
                          childInspect.history_score_2 === 0
                            ? childInspect.history_score_2
                            : '&nbsp;'
                        }}
                      </div>
                      <div>
                        {{
                          childInspect.history_score_3 ||
                          childInspect.history_score_3 === 0
                            ? childInspect.history_score_3
                            : '&nbsp;'
                        }}
                      </div>
                    </div>
                    <!-- 改善项目 -->
                    <div
                      class="exportTemplate_main_inspection_details_main_item_value"
                      :style="{
                        flex:
                          '0 0 ' +
                          translateTitle(
                            'width.exportTemplateDialog.inspection_details.table_column9'
                          ),
                      }"
                    >
                      {{ childInspect.comment }}
                    </div>
                  </div>
                </div>
              </div>
            </template>
          </div>
          <div v-else class="no-data no-break">
            {{ translateTitle('label.menu.zanwushuju') }}
          </div>
        </div>
        <!-- 检查明细表（图片）-->
        <div
          v-if="!isTemplate"
          class="exportTemplate_main_photos no-break page-break"
        >
          <div class="exportTemplate_main_photos_header">
            <!-- 大项目 -->
            <div
              class="exportTemplate_main_photos_header_item blue-label"
              :style="{
                flex: `0 0 calc(${translateTitle(
                  'width.exportTemplateDialog.photos.table_column1'
                )} + 1px
                    )`,
              }"
            >
              {{ translateTitle('label.menu.daxiangmu') }}
            </div>
            <!-- no -->
            <div
              class="exportTemplate_main_photos_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.photos.table_column2'
                  ),
              }"
            >
              {{ translateTitle('label.menu.fanhao') }}
            </div>
            <!-- 确认内容 -->
            <div
              class="exportTemplate_main_photos_header_item blue-label"
              :style="{
                flex:
                  '0 0 ' +
                  translateTitle(
                    'width.exportTemplateDialog.photos.table_column3'
                  ),
              }"
            >
              {{ translateTitle('label.menu.querenneirong') }}
            </div>
            <!-- 图片详细 -->
            <div
              class="exportTemplate_main_photos_header_item blue-label auto-width"
              :style="{
                'min-width': `calc(${translateTitle(
                  'width.exportTemplateDialog.photos.table_column4'
                )} + ${translateTitle(
                  'width.exportTemplateDialog.photos.table_column5'
                )})`,
              }"
            >
              {{ translateTitle('label.menu.tupianxiangxi') }}
            </div>
          </div>
          <div
            v-if="item.picList && item.picList.length > 0"
            class="exportTemplate_main_photos_main"
          >
            <template v-for="(inspect, inspectIndex) in item.picList">
              <template
                v-if="
                  inspectIndex > 0 &&
                  inspect.pageIndex != item.picList[inspectIndex - 1].pageIndex
                "
              >
                <div
                  :key="inspectIndex + 'emptyDiv' + 'picList'"
                  class="emptyDiv"
                  :style="{ height: inspect.blankHeight + 'px' }"
                ></div>
                <div
                  :key="inspectIndex + 'emptyDiv' + 'picHead'"
                  class="exportTemplate_main_photos_header"
                >
                  <!-- 大项目 -->
                  <div
                    class="exportTemplate_main_photos_header_item blue-label"
                    :style="{
                      flex: `0 0 calc(${translateTitle(
                        'width.exportTemplateDialog.photos.table_column1'
                      )} + 1px
                    )`,
                    }"
                  >
                    {{ translateTitle('label.menu.daxiangmu') }}
                  </div>
                  <!-- no -->
                  <div
                    class="exportTemplate_main_photos_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.photos.table_column2'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.fanhao') }}
                  </div>
                  <!-- 确认内容 -->
                  <div
                    class="exportTemplate_main_photos_header_item blue-label"
                    :style="{
                      flex:
                        '0 0 ' +
                        translateTitle(
                          'width.exportTemplateDialog.photos.table_column3'
                        ),
                    }"
                  >
                    {{ translateTitle('label.menu.querenneirong') }}
                  </div>
                  <!-- 图片详细 -->
                  <div
                    class="exportTemplate_main_photos_header_item blue-label auto-width"
                    :style="{
                      'min-width': `calc(${translateTitle(
                        'width.exportTemplateDialog.photos.table_column4'
                      )} + ${translateTitle(
                        'width.exportTemplateDialog.photos.table_column5'
                      )})`,
                    }"
                  >
                    {{ translateTitle('label.menu.tupianxiangxi') }}
                  </div>
                </div>
              </template>
              <div
                :key="inspectIndex + 'picList' + 'y'"
                class="exportTemplate_main_photos_main_item"
              >
                <!-- 大项目 -->
                <div
                  class="exportTemplate_main_photos_main_item_value center"
                  :style="{
                    flex: `0 0 ${translateTitle(
                      'width.exportTemplateDialog.photos.table_column1'
                    )}
                    `,
                  }"
                >
                  <div class="itemAtegory">
                    <div
                      v-for="(
                        itemAtegoryChild, itemAtegoryIndex
                      ) in inspect.item_ategory_list"
                      :key="itemAtegoryIndex + 'item_ategory_list'"
                    >
                      {{
                        translateTitle(itemAtegoryChild.key, true) ||
                        itemAtegoryChild.name
                      }}
                    </div>
                  </div>
                </div>
                <div class="exportTemplate_main_photos_main_item_right">
                  <div
                    v-for="(
                      childInspect, childInspectIndex
                    ) in inspect.children"
                    :key="inspectIndex + 'picList' + childInspectIndex"
                    class="exportTemplate_main_photos_main_item_right_content"
                    :class="childInspectIndex > 0 ? 'topBorder' : ''"
                  >
                    <!-- no -->
                    <div
                      class="exportTemplate_main_photos_main_item_value center no"
                      :style="{
                        flex:
                          '0 0 ' +
                          translateTitle(
                            'width.exportTemplateDialog.photos.table_column2'
                          ),
                      }"
                    >
                      {{
                        caccumulationNo(
                          inspectIndex,
                          childInspectIndex,
                          item.picList
                        )
                      }}
                    </div>
                    <!-- 确认内容 -->
                    <div
                      class="exportTemplate_main_photos_main_item_value"
                      :style="{
                        flex:
                          '0 0 ' +
                          translateTitle(
                            'width.exportTemplateDialog.photos.table_column3'
                          ),
                      }"
                    >
                      <span
                        class="rich-text-pc"
                        v-html="childInspect.item_content"
                      ></span>
                    </div>
                    <!-- 图片详细 -->
                    <div class="exportTemplate_main_photos_main_item_pics">
                      <div
                        v-for="num in 2"
                        :key="num + 'num'"
                        class="exportTemplate_main_photos_main_item_pic"
                      >
                        <div
                          class="exportTemplate_main_photos_main_item_value center"
                          :style="{
                            flex:
                              '0 0 ' +
                              translateTitle(
                                'width.exportTemplateDialog.photos.table_column4'
                              ),
                          }"
                        >
                          {{
                            translateTitle(
                              'label.menu.' + (num == 1 ? 'queshi' : 'gaishan')
                            )
                          }}
                        </div>
                        <div
                          class="exportTemplate_main_photos_main_item_value imgs"
                        >
                          <!-- 缺失图片 -->
                          <div v-if="num == 1" class="images">
                            <div
                              v-for="(
                                reportItem, reportIndex
                              ) in childInspect.report_pic"
                              :key="reportIndex + 'report_pic'"
                            >
                              <img
                                v-if="
                                  !reportItem.name
                                    .toLowerCase()
                                    .endsWith('.mp4') &&
                                  !reportItem.name
                                    .toLowerCase()
                                    .endsWith('.mov')
                                "
                                :src="reportItem.url"
                              />
                              <img v-else :src="reportItem.coverUrl" />
                            </div>
                          </div>
                          <!-- 改善图片 -->
                          <div v-else class="images">
                            <div
                              v-for="(
                                improveItem, improveIndex
                              ) in childInspect.improve_pic"
                              :key="improveIndex + 'improve_pic'"
                            >
                              <img
                                v-if="
                                  !improveItem.name
                                    .toLowerCase()
                                    .endsWith('.mp4') &&
                                  !improveItem.name
                                    .toLowerCase()
                                    .endsWith('.mov')
                                "
                                :src="improveItem.url"
                              />
                              <img v-else :src="improveItem.coverUrl" />
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </template>
          </div>
          <div v-else class="no-data no-break">
            {{ translateTitle('label.menu.zanwushuju') }}
          </div>
        </div>
        <!-- 把企业名称挤到下一页上 -->
        <div
          v-if="list && list.length > 1 && index < list.length - 1"
          class="no-break page-break"
        ></div>
      </div>
    </div>
  </div>
</template>
<script>
  
  import PdfLoader from '@/utils/pdfLoader.js'

  export default {
    name: 'ExportTemplateDialog',
    data() {
      return {
        dialogVisible: false,
        list: [],
        isTemplate: true, // 是不是模板导出
        itemCategories: [],
              displaylevels: null, // 大项目显示层数
        setInfo: {},
        exportLoading: false,
        langKey: Math.random(),
      }
    },
    created() {
      this.getCodes()
    },
    methods: {
      translateTitle,
      getCodeLabel,
      dayjs,
      /**
       * @param {Object} queryForm 查询条件
       * @param {Boolean} isTemplate 是否是模板导出 默认是模板导出
       * @param {Number} set_rid 实施id
       * @param {String} type all:全部导出,search_form:根据筛选条件导出
       */
      async show({
        isTemplate,
  
        callback = () => {},
      }) {
        let list = []
       
        const result = await this.configListData(list)
        this.list = result
        this.isTemplate = isTemplate
        this.langKey = Math.random()
        this.$nextTick(() => {
          let pdfName ='demo'
          if (!isTemplate) {
            const sv_name = this.setInfo.sv_name
            const org_name = this.setInfo.org_name
            const month = this.setInfo.month
            pdfName = `${sv_name}_${org_name}_${month}`
          }
          let pdf = new PdfLoader(
            document.querySelector('#print_main'),
            pdfName,
            'no-break',
            'page-break'
          )

          let list = this.list
          list = pdf.setTableHeight(
            list,
            'inspectionList',
            'exportTemplate_main_inspection_top',
            'exportTemplate_main_inspection_details_header',
            'exportTemplate_main_inspection_details_main',
            'exportTemplate_main_inspection_details_main_item'
          )
          if (!this.isTemplate) {
            list = pdf.setTableHeight(
              list,
              'picList',
              null,
              'exportTemplate_main_photos_header',
              'exportTemplate_main_photos_main',
              'exportTemplate_main_photos_main_item'
            )
          }
          this.list = list
          this.$nextTick(() => {
            pdf.splitPages()
            this.printPdf(pdf, callback)
          })
        })
      },
      // 获取选择检查表和店铺的模板数据
      async getTemplateList(queryForm) {
        let queryParams = {}
        queryForm.list_rids && queryForm.list_rids.length > 0
          ? (queryParams.list_rids = JSON.stringify(queryForm.list_rids))
          : ''
        queryForm.org_rids && queryForm.org_rids.length > 0
          ? (queryParams.org_rids = JSON.stringify(queryForm.org_rids))
          : ''
        const { data } = await getTemplateData(queryParams)
        return data
      },
      // 获取qsc实施进入导出的模板数据
      async getSetInfo(set_rid, queryForm, type) {
        const { data } = await getSetInfo({ set_rid })
        const list = await this.getExportData(set_rid, queryForm, type)
        data.list = list
        this.setInfo = data
        return [data]
      },
      async getExportData(set_rid, queryForm, type) {
        let searchList = {
          set_rid: set_rid,
          is_export: true,
        }
        // type == search_form 添加根据筛选条件导出
        if (type == 'search_form') {
          searchList.item_content = queryForm.item_content // 确认内容
          searchList.score = queryForm.score // 评分
          queryForm.item_ategories && queryForm.item_ategories.length > 0
            ? (searchList.item_ategories = JSON.stringify(
                queryForm.item_ategories.map(Number)
              ))
            : null
          searchList.filter_conditions =
            queryForm.filter_conditions?.length > 0
              ? queryForm.filter_conditions.join(',')
              : null
        }
        const {
          data: { list },
        } = await getList(searchList)
        return list
      },
      async configListData(data) {
        let list = data
        for (const s of list) {
          for (const v of s.list) {
            v.standard = JSON.parse(v.standard)
            v.rating_condition = v.rating_condition == 0 ? true : false
            v.report_pic = v.report_pic ? JSON.parse(v.report_pic) : []
            v.improve_pic = v.improve_pic ? JSON.parse(v.improve_pic) : []
            // 显示固定层数的大项目
          }
          s.inspectionList = s.list.map((d) => {
            return {
              item_ategory: d.item_ategory,
              item_ategory_list: d.item_ategory_list,
              children: [d],
            }
          })
          s.picList = s.list
            .filter((f) => f.report_pic.length > 0 || f.improve_pic.length > 0)
            .map((d) => {
              return {
                item_ategory: d.item_ategory,
                item_ategory_list: d.item_ategory_list,
                children: [d],
              }
            })
        }
        return list
      },
      getItemCategorieName(item_ategory, itemCategories) {
        if (!item_ategory && item_ategory != 0) {
          return null
        }
        const children = this.getItemCategorieChildren(itemCategories)
        const list = itemCategories.concat(children)
        const itemCategorieObj = list.find((s) => s.code_value == item_ategory)
        return itemCategorieObj ? itemCategorieObj.code_description : null
      },
      getItemCategorieChildren(itemCategories) {
        let list = []
        function recurse(itemCategories) {
          const children = itemCategories
            .flatMap((m) => m.children)
            .filter((f) => f && f.code_value)
          list = list.concat(children)
          if (children && children.length > 0) {
            recurse(children)
          }
        }
        recurse(itemCategories)
        return list
      },
      getInspectionList(setDetailList) {
        let result = []
        let prevPageIndex = null
        let prevItemCategory = null
        let prevMultiPages = false
        for (const setDetail of setDetailList) {
          // 如果当前项和上一项在同一页，并且大项目相同，则合并
          if (
            prevPageIndex === setDetail.pageIndex &&
            prevItemCategory === setDetail.item_ategory &&
            !prevMultiPages &&
            !setDetail.multiPages
          ) {
            const group = result[result.length - 1]
            group.height += setDetail.height
            group.children.push(setDetail.children[0])
          } else {
            result.push({
              item_ategory: setDetail.item_ategory,
              item_ategory_list: setDetail.item_ategory_list,
              pageIndex: setDetail.pageIndex,
              height: setDetail.height,
              blankHeight: setDetail.blankHeight,
              children: [setDetail.children[0]],
            })
          }
          prevPageIndex = setDetail.pageIndex
          prevItemCategory = setDetail.item_ategory
          prevMultiPages = setDetail.multiPages
        }
        return result
      },

      caccumulationNo(parentIndex, childIndex, list) {
        let baseIndex = 0
        for (let i = 0; i < parentIndex; i++) {
          baseIndex += list[i].children.length // 累加前面所有父节点的子节点总数
        }
        return baseIndex + childIndex + 1
      },
      handleClose() {
        this.setInfo = {}
        this.dialogVisible = false
      },
      itemAtegoryListRowspan(list, index) {
        const standard = list[index].children.map((m) => m.standard.length + 1)
        const standardLength = standard.reduce((accumulator, currentValue) => {
          return accumulator + currentValue
        }, 0)
        return standardLength
      },
      async printPdf(pdf, callback) {
        this.$message({
          showClose: true,
          message: 123,
          type: 'success',
          duration: 4000,
        })
        await pdf.getPDF()
        callback()
      },
    },
  }
</script>
<style lang="scss" scoped>
  .exportTemplateDialog {
    width: 960px;
    // height: 50px;
    // position: absolute;
    // top: -100px;
    // left: -1500px;
    // overflow-y: auto;
  }
  #print_main {
    width: 960px;
    height: 100%;
    background-color: #fff;
  }
  @mixin justify-center {
    display: flex;
    justify-content: center;
  }
  @mixin align-center {
    display: flex;
    align-items: center;
  }
  @mixin center {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  $blue-bgc: #5b9bd5;
  $line-color: #000;
  .blue-label {
    background-color: $blue-bgc;
    color: #000;
    font-weight: bold;
  }
  ::v-deep {
    .el-dialog {
      min-width: 1000px;
    }
    td,
    th {
      height: 40px;
      line-height: 1.5;
      border: none;
    }
    tr {
      td + td {
        border-right: 1px solid $line-color;
      }
      td {
        border-top: 1px solid $line-color;
        border-left: 1px solid $line-color;
      }
      &:last-child {
        td {
          border-bottom: 1px solid $line-color;
        }
      }
    }
    table {
      border-color: $line-color;
    }
  }
  .exportTemplateDialog {
    .exportTemplate {
      &_buttons {
        @include justify-center;
      }
      &_main {
        &_title {
          @include justify-center;
          font-size: 90px;
          line-height: 96px;
        }
        .large-font-size {
          font-size: 18px;
        }

        &_estimate {
          width: 65%;
          margin: 0 auto;
          border: 2px solid $line-color;
          min-height: 300px;
          padding: 5px;
          box-sizing: border-box;
        }
        .center {
          @include center;
          &.column {
            flex-direction: column;
          }
        }
        .no-data {
          width: 100%;
          text-align: center;
          height: 40px;
          line-height: 40px;
          border: 2px solid $line-color;
          border-top: none;
        }
        &_inspection_details {
          width: 100%;
          overflow-x: auto;
          overflow-y: hidden;
          .auto-width {
            width: 100%;
          }
          &_header {
            display: flex;
            border: 1px solid $line-color;
            &_item {
              border: 1px solid $line-color;
              min-height: 40px;
              @include center;
              padding: 0 5px;

              &.left {
                justify-content: flex-start;
              }
            }
            div + div {
              border-left: none;
            }
          }
          &_main {
            &_item {
              display: flex;
              border: 1px solid $line-color;
              border-top: none;
              line-height: 18px;
              &_childInspect {
                flex: 1;
                display: flex;
              }
              &_childInspect.topBorder {
                border-top: 1px solid $line-color;
              }
              &_value {
                border: 1px solid $line-color;
                min-height: 40px;
                padding: 5px;
                border-top: none;
                word-break: break-all;
              }
              &_project {
                display: flex;
                flex-direction: column;
                &_item {
                  display: flex;
                  flex: 1;
                }
              }
              &_right {
                flex: 1;
                display: flex;
                flex-direction: column;
              }
              .score_area {
                display: flex;
                flex-direction: column;
                row-gap: 5px;
                div {
                  text-align: center;
                }
              }
            }
          }
        }
        &_photos {
          width: 100%;
          overflow-x: auto;
          overflow-y: hidden;
          .auto-width {
            width: 100%;
          }
          &_header {
            display: flex;
            border: 1px solid $line-color;
            &_item {
              min-height: 40px;
              @include center;
              border: 1px solid $line-color;
              padding: 0 5px;
            }
            div + div {
              border-left: none;
            }
          }
          &_main {
            &_item {
              display: flex;
              border: 1px solid $line-color;
              border-top: none;
              line-height: 18px;
              &_right {
                flex: 1;
                display: flex;
                flex-direction: column;
                &_content {
                  flex: 1;
                  display: flex;
                }
                &_content.topBorder {
                  border-top: 1px solid $line-color;
                }
              }

              &_value {
                border: 1px solid $line-color;
                min-height: 40px;
                padding: 5px;
                border-top: none;
                word-break: break-all;
              }
              &_pics {
                display: flex;
                flex-direction: column;
                flex: 1;
              }
              &_pic {
                flex: 1;
                display: flex;
              }
              .imgs {
                flex: 1;
              }
              .images {
                display: flex;
                flex-wrap: wrap;
                row-gap: 10px;
                div {
                  width: 180px;
                  height: 100px;
                  @include justify-center;
                }
                img {
                  width: auto;
                  height: auto;
                  max-width: 100%;
                  max-height: 100%;
                }
              }
            }
          }
        }
        &_score {
          width: 60%;
          margin: 0px auto;
          &_head {
            display: flex;
            border: 1px solid $line-color;
            border-bottom: none;
            &_item {
              min-height: 40px;
              @include center;
              border: 1px solid $line-color;
              padding: 0 5px;
            }
            div + div {
              border-left: none;
            }
          }
          &_main {
            display: flex;
            flex-direction: column;
            &_body {
              flex: 1;
              display: flex;
              border: 1px solid $line-color;
              border-top: none;
              &:last-child {
                border-bottom-width: 2px;
              }
            }
            &_body_item {
              flex: 1;
              display: flex;

              div {
                flex: 1;
                min-height: 40px;
                @include center;
                padding: 5px;
                border: 1px solid $line-color;
                border-top: none;
                border-bottom: none;
              }
              &_label {
                width: 50%;
              }

              .border-right-none {
                border-right: none;
              }
            }
          }
        }
      }
    }
  }
  .no {
    border-right: none !important;
  }
  .itemAtegory {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    height: min-content;
    row-gap: 5px;
    div {
      text-align: center;
    }
  }

  .right-border {
    border-right: 2px solid $line-color !important;
  }

  .rich-text-pc {
    white-space: break-spaces;
    word-break: break-all;
    ::v-deep p {
      max-width: 100%;
      margin-block-start: 0;
      margin-block-end: 0;
      white-space: break-spaces;
      word-break: break-all;
    }
  }
  .exportTemplate_main_inspection_details_main_item_right {
    .exportTemplate_main_inspection_details_main_item_value {
      border-left: none;
    }
  }

  .custom_check {
    width: 13px;
    height: 13px;
    border-radius: 1px;
    border: 1px solid #000;
  }
  .is-checked {
    width: 16px;
    height: 16px;
  }
  .exportTemplate_main_score_main_body_item {
    & + & {
      div {
        border-left: none;
      }
    }
  }
</style>
